package com.cskaoyan.controller.wx;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.collect.CollectData;
import com.cskaoyan.service.wx.CollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @author xudengfeng
 * @date 2020/12/8 16:40
 */
@RestController
@RequestMapping("wx/collect")
public class CollectController {

    @Autowired
    CollectService collectService;

    @GetMapping("list")
    public BaseRespVo list(Byte type, Integer page, Integer size) {
        CollectData collectData = collectService.getCollectList(type, page, size);
        return BaseRespVo.ok(collectData);
    }


    @PostMapping("addordelete")
    public BaseRespVo addOrDeleteCollect(@RequestBody Map map) {
        String type = collectService.addOrDeleteCollect(map);

        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("type", type);
        return BaseRespVo.ok(hashMap);
    }
}
